package com.zyh.kaoshi;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.Date;

public class Test1 {
    public static void main(String[] args) throws ParseException {
        String str="2021-08-12";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date parse = sdf.parse(str);
        int year = parse.getYear() + 1900;
        System.out.println("year = " + year);
        int month = parse.getMonth() + 1;
        System.out.println("month = " + month);
        int date = parse.getDate();
        System.out.println("date = " + date);
        /*String format = sdf.format(parse);
        System.out.println("format = " + format);*/
    }
}
